
//TODO a(19)
function a19(module, exports) {
    var a = function () {
        this._hash = {}, this._cid = 1, this._ckey = "_nx_msg_ckey"
    };
    a.prototype = {
        add: function (e, t, a) {
            if (e && t) {
                t.ctx = a;
                var i = t[this._ckey];
                i || (t[this._ckey] = i = this._cid++), (this._hash[e] = this._hash[e] || {})[i] = t
            }
        }, remove: function (e, t, a) {
            if (e && t) {
                var i = t[this._ckey];
                if (this._hash[e] && i && this._hash[e][i] && this._hash[e][i].ctx == a) {
                    delete this._hash[e][i];
                    for (var s in this._hash[e])return;
                    delete this._hash[e]
                }
            }
        }, send: function (e, t) {
            if (this._hash[e]) {
                var a = [];
                for (var i in this._hash[e])a.push(i);
                (function () {
                    for (; a.length;)try {
                        var t = this._hash[e][a.shift()];
                        t.apply(t.ctx || null, arguments)
                    } catch (i) {
                        throw i
                    } finally {
                        arguments.callee.apply(this, arguments)
                    }
                }).apply(this, arguments)
            }
        }
    };
    var i = function () {
        this._cache = {}, this.msg = new a
    };
    i.prototype = {
        on: function (e, t, a) {
            this.msg.add(e, t, a)
        }, one: function (e, t, a) {
            var i = this, s = function () {
                i.msg.remove(e, s, a), t.apply(a, arguments)
            };
            this.msg.add(e, s, a)
        }, off: function (e, t, a) {
            this.msg.remove(e, t, a)
        }, set: function (e, t, a) {
            this._cache[e] = t, a || this.msg.send(e, t)
        }, get: function (e) {
            return this._cache[e]
        }
    }, module.exports = i
}
